<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet" type="text/css" href="css/common.css"/>
	<link rel="stylesheet" type="text/css" href="css/article_list.css"/>
</head>
<body>
<form action="" method="post" class="search_box">
	<span>推广人员：<input type="text" id="name" name="name"/></span>
	<span>推广内容：<input type="text" id="typeName" name="typeName"/></span>
	<span>统计日期：<input type="text" id="beginTime" name="beginTime"/>-<input type="text" id="endTime" name="endTime"/></span>
	<button type="button" class="sub">搜索</button>
</form>
<div id="list_content">

</div>

<div style="text-align: center;width: 100%;height: 50px;">
	<div class="tcdPageCode" style="display: inline-block;"></div>
	<div class="totalNum" style="display: inline-block;">共<b style="color: #FD482C;font-weight: bold;margin: 0 5px;" id="totalNum">300</b>条</div>
</div>
<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="layui/layui.js"></script>
<script src="js/jquery.page.js" type="text/javascript" charset="utf-8"></script>
<script>
			jQuery.browser = {};
			(function() {
				jQuery.browser.msie = false;
				jQuery.browser.version = 0;
				if(navigator.userAgent.match(/MSIE ([0-9]+)./)) {
					jQuery.browser.msie = true;
					jQuery.browser.version = RegExp.$1;
				}
			})();

			var params = {
				name:'', //姓名
				typeName:'',
				limit: 10, //记录数
				offset: 1 //页码
			};
			layui.use(['element', 'form', 'laydate', 'layedit'],
			function() {
			   var laydate = layui.laydate;
					laydate.render({
							elem: '#beginTime' //指定元素
					});
					laydate.render({
							elem: '#endTime' //指定元素
					});

				search();//搜索

					//绑定搜索事件
					$(".sub").click(function() {
						params.name = $("#name").val();
						params.typeName = $("#typeName").val();
						params.beginTime = $("#beginTime").val();
						params.endTime = $("#endTime").val();
						search();
					});

			});

			//查询方法
			function search() {

				$.ajax({
					url: '/log/list',
					type: 'get',
					data: params,
					dataType: "json",
					success: function(data) {
					  $("#totalNum").text(data.total);
						var headTable = "<table border='0' cellspacing='0' cellpadding='0'><tr><th >推广人员</th>" +
							"<th>推广内容</th><th>扫码时间</th><th>扫码手机</th></tr>";
						var contentHtml = "";
						if(data.rows) {
							var reg = new RegExp(",", "g");
							for(var i = 0; i < data.rows.length; i++) {
								var obj = data.rows[i];
								contentHtml += "<tr><td>" + obj.name + "</td><td>" + obj.typeName + "</td>" +
									"<td  >" + obj.crtTime + "</td>"+	"<td  >" + obj.crtUser + "</td></tr>";
							}
						} else {
							contentHtml = "<tr><td colspan='4'>暂无记录</td></tr>";
						}

						$("#list_content").html(headTable + contentHtml + "</table>");

						$(".tcdPageCode").createPage({
							pageCount: data.totalPages,
							current: data.page,
							backFn: function(p) {
								//console.log(p);
								params.offset = p;
								search();
							}
						});
					}
				});
			}

			document.onkeydown = function(event){
				var e = event || window.event || arguments.callee.caller.arguments[0];
				if(e && e.keyCode == 116){
					event.preventDefault();

					$(window.parent.$('.showIframe').each(function(){
						if(!$(this).hasClass('hideIframe')){
							$(this).children('iframe').attr('src',$(this).children('iframe').attr('src'))
						}
					}))
				}
			}
		</script>
</body>
</html>
